package com.alquimia.identityaccess.application.events.user;

import com.alquimia.identityaccess.application.events.UpdatedEvent;
import com.alquimia.identityaccess.domain.model.User;

/**
 * Created by Ivo on 16/07/2014.
 */
public class UserPersonalNameUpdatedEvent extends UpdatedEvent {

    private String userId;
    private String firstName;
    private String lastName;

    public UserPersonalNameUpdatedEvent(User aUser) {
        super();

        this.initializeFrom(aUser);
    }

    public UserPersonalNameUpdatedEvent(String aUserId) {
        super();

        this.userId = aUserId;
    }


    public String getFirstName() {
        return firstName;
    }

    public String getLastName() {
        return lastName;
    }

    public String getUserId() {
        return userId;
    }


    private void initializeFrom(User aUser) {
        this.firstName = aUser.person().fullName().firstName();
        this.lastName = aUser.person().fullName().lastName();
        this.userId = aUser.userId().id().toString();
    }

    public static UserPersonalNameUpdatedEvent notFound(String aUserId) {
        UserPersonalNameUpdatedEvent userPersonalNameUpdatedEvent = new UserPersonalNameUpdatedEvent(aUserId);
        userPersonalNameUpdatedEvent.entityFound = false;
        return userPersonalNameUpdatedEvent;
    }


}
